package com.googlecode.agscrum.controller.jsf.bean;

import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.googlecode.agscrum.model.entity.User;
import com.googlecode.agscrum.model.service.Service;
import com.googlecode.agscrum.model.util.Criteria;
import com.googlecode.agscrum.model.util.Restrictions;


@Controller("userControllerBean")
@Scope("request")
@Configurable(autowire = Autowire.BY_NAME)
public class UserControllerBean extends BaseControllerBean<User, Long>{
	
	private Service<User, Long> userService;

	public void setUserService(Service<User, Long> userService) {
		this.userService = userService;
	}
	
	@Override
	protected Criteria getCriteria() {
		Criteria criteria = Criteria.getInstance("User.searchQuery",
				User.class);
		criteria.addAnd(Restrictions.ilike("u.name", true, getEntity()
				.getName(), true));
		return criteria;
	}
	
	@Override
	public String save() {
		return super.save();
	}

	@Override
	protected Service<User, Long> getService() {
		return userService;
	}

	@Override
	protected void reset() {
		// TODO Auto-generated method stub
		
	}

}
